package com.example.personnel_oa.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.comment_oa.pojos.Talentpool;
import com.example.comment_oa.pojos_vo.Talentpool_vo;
import com.example.personnel_oa.mapper.TalentpoolMapper;


import com.example.personnel_oa.service.TalentpoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author asus
* @description 针对表【talentpool】的数据库操作Service实现
* @createDate 2022-10-13 11:23:21
*/
@Service
public class TalentpoolServiceImpl extends ServiceImpl<TalentpoolMapper, Talentpool>
implements TalentpoolService {
    @Autowired
    TalentpoolMapper talentpoolMapper;

//    //查询出所有人才
//    @Override
//    public List<Talentpool> Talentpool() {
//        QueryWrapper<Talentpool> wrapper = new QueryWrapper<>();
//        QueryWrapper<Talentpool> talentpool = wrapper.gt("talents_state", 1);
//        return talentpoolMapper.selectList(talentpool);
//    }

    //查询出所有人才
    @Override
    public List<Talentpool> Talentpool() {
        List<Talentpool> talentpool = talentpoolMapper.Talentpool();
        return talentpool;
    }

    @Override
    public int insertTalentpool(Talentpool talentpool) {
            //新增人才
            int insert = talentpoolMapper.Insert(talentpool);
                if(insert < 0){
                    return 0;
                }else {
                    return 10;
                }

    }
    //新增关注
    @Override
    public int Insertguanzhu(Talentpool talentpool) {
        int qq;
        int insertguanzhu = talentpoolMapper.Insertguanzhu(talentpool);
        if(insertguanzhu>0){
            Talentpool aa = talentpoolMapper.aa();
             qq = aa.getTalentsId();
            System.out.println(aa);
            if(aa != null){
                int in = talentpoolMapper.insertguanzhu(qq, talentpool.getEmpId());
                if(in>0){
                    int bb = talentpoolMapper.bb(qq);
                }
            }
            return 11;
        }else {
            return 0;
        }

    }


    //删除人才
    @Override
    public int deleteTalentpool(int id) {
        return talentpoolMapper.deleteTalentpool(id);

    }

    //  根据输入框中的内容进行条件查询
    @Override
    public List<Talentpool> selectTalentpool(Talentpool talentpool) {
        List<Talentpool> talentpools = talentpoolMapper.selectTalentpool(talentpool);
        return talentpools;
    }

    //简历模块查询全部
    @Override
    public List<Talentpool> selectjianli() {
        List<Talentpool> selectjianli = talentpoolMapper.selectjianli();
        return selectjianli;
    }
    //新增简历
    @Override
    public int insertResume(Talentpool talentpool) {
        int i = talentpoolMapper.insertResume(talentpool);
        if(i < 0){
            return 0;
        }else {
            return 2;
        }

    }

    //添加到人才库
    @Override
    public int update(String talentsTalenttag,int id) {
        int update = talentpoolMapper.update(talentsTalenttag,id);
        if(update < 0){
            return 0;
        }else {
            return 4;
        }
    }

    //添加人才库
    @Override
    public int update2(int id) {
        int i = talentpoolMapper.update2(id);
        if(i < 0){
            return 0;
        }else {
            return 4;
        }
    }

    //简历的高级查询
    @Override
    public List<Talentpool> selectResume(Talentpool_vo talentpoolVo) {
        List<Talentpool> talentpools = talentpoolMapper.selectResume(talentpoolVo);
        return talentpools;
    }

    @Override
    public Talentpool resumeId(int talentsId) {
        Talentpool talentpool = talentpoolMapper.resumeId(talentsId);
        return talentpool;
    }

    //查询我的关注
    @Override
    public List<Talentpool> wodeguanzhu(int empId) {
        List<Talentpool> wodeguanzhu = talentpoolMapper.wodeguanzhu(empId);
        return wodeguanzhu;
    }

    //添加关注
    @Override
    public int insertguanzhu(int talentsId, int empId) {
        int insertguanzhu = talentpoolMapper.insertguanzhu(talentsId, empId);
        if(insertguanzhu < 0){
            return 0;
        }else {
            return 1;
        }
    }

    //取消关注
    @Override
    public int delguanzhu(int talentsId, int empId) {
        int delguanzhu = talentpoolMapper.delguanzhu(talentsId, empId);
        if(delguanzhu < 0){
            return 0;
        }else {
            return 1;
        }
    }

    //根据人才id和关注人查询有没有这条数据
    @Override
    public Talentpool jiaoyangz(int talentsId, int empId) {
        Talentpool jiaoyangz = talentpoolMapper.jiaoyangz(talentsId, empId);
        return jiaoyangz;
    }

    @Override
    public int deleteTalentpools(int id) {
        int i = talentpoolMapper.deleteTalentpools(id);
        return i;
    }

    //我的关注页面的搜索数据
    @Override
    public List<Talentpool> selectguanzhu(Talentpool_vo talentpoolVo) {
        List<Talentpool> selectguanzhu = talentpoolMapper.selectguanzhu(talentpoolVo);
        return selectguanzhu;
    }

    //根据id查询人才
    @Override
    public Talentpool offerTalentpool(int talentsId) {
        Talentpool talentpool = talentpoolMapper.offerTalentpool(talentsId);
        return talentpool;
    }


}
